home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / basic / BlitzC2P.lha / blitzc2p / c2p / c2pCACHE.ascii < prev    next >
Encoding:
Text File  |  1998-07-31  |  10.5 KB  |  492 lines

  1. WBStartup
  2. NoCli
  3.  
  4. ; Results on 030/50
  5. ; PAL 320x200 @23.5fps
  6. ; PAL 320x256 @18.0fps
  7.  
  8. ; Results on 040/25Mhz CPU:
  9. ; PAL       50Hz 320x200 256-colours runs @50fps
  10. ; DoublePAL 48Hz 320x200 256-colours runs @47.1fps
  11. ; PAL       50Hz 320x256 256-colours runs @38.3fps
  12. ; DoublePAL 48Hz 320x256 256-colours runs @35.3fps
  13.  
  14. ; Results on 060/50:
  15. ; PAL @49.6fps 320x256
  16. ; PAL @66.1fps 320x200
  17.  
  18. ;Width must be multiple of 32!
  19. #scrwidth=320 ; This is the width of chunky bitmap and also of the planar bitmap
  20. #scrheight=256 ; This is the height of the chunky bitmap and also of the planar bitmap
  21.  
  22. #screensize=#scrwidth*#scrheight ; constants needed by the c2p
  23. #screensize4=#screensize/4
  24. #plane=#screensize/8
  25.  
  26. Statement c2p{A.l,B.l}
  27. .c2p
  28.  
  29.   MOVE.l  d0,a0
  30.   MOVE.l  d1,a1
  31.  
  32. ;Original sourcecode text:
  33. ;
  34. ;---------------------------------------------------------------------------
  35. ;5 pass cpu only c2p for 040/060 -
  36. ;
  37. ;~13820us for 320x256 (216 rasterlines)
  38. ;with no dma activated.
  39. ;(usual copyspeed is ~13960 us)
  40. ;
  41. ;(W) Mai 1998 by Tim Bvscke aka. Azure
  42. ;azure@gmx.net
  43. ;
  44. ;This Chunky to Planar converter is converting/writing faster than
  45. ;a usual longword loop is copying from fastmem to chipmem. (Copyspeed)
  46. ;
  47. ;This is possible due to some caching-tricks.
  48. ;
  49. ;---------------------------------------------------------------------------
  50. ;IN:
  51. ; a0   =source
  52. ; a1   =target
  53. ;----------------------------------------------------------------------------
  54.  
  55.  
  56.  
  57. ;MERGE    d1,d2,tmp,mask,shift
  58. Macro MERGE
  59.   MOVE.l   `2,`3
  60.   LSR.l   #`5,`3
  61.     EOR.l    `1,`3
  62.     AND.l    `4,`3
  63.     EOR.l    `3,`1
  64.     LSL.l   #`5,`3
  65.     EOR.l    `3,`2
  66. End Macro
  67.  
  68. Macro MERGE1
  69.   MOVE.l   `2,`3
  70.   LSR.l    #1,`3
  71.     EOR.l    `1,`3
  72.     AND.l    `4,`3
  73.     EOR.l    `3,`1
  74.     ADD.l    `3,`3
  75.     EOR.l    `3,`2
  76. End Macro
  77.  
  78. Macro MERGEw
  79.     SWAP  `2
  80.     EOR.w `1,`2
  81.     EOR.w `2,`1
  82.     EOR.w `1,`2
  83.     SWAP  `2
  84. End Macro
  85.  
  86. _chunky2planar
  87.  
  88.     MOVEM.l a3-a6,-(a7)
  89.     MOVE.l  #screensize,d0
  90.  
  91.     LEA 0(a0,d0.l),a2
  92.     MOVE.l  a2,smc+2
  93.  
  94.     MOVEM.l a0/a1/a6,-(a7)
  95.     MOVE.l  $4,a6
  96.     JSR -636(a6)  ;flush caches
  97.     MOVEM.l (a7)+,a0/a1/a6
  98.  
  99.     MOVE.l  (a0),d0
  100.     MOVE.l  2*4+0(a0),d2
  101.     MOVE.l  4*4+0(a0),d4
  102.     MOVE.l  6*4+0(a0),d6
  103.  
  104.     !MERGEw{d0,d4}
  105.     !MERGEw{d2,d6}
  106.  
  107.     !MERGE{d0,d2,d3,#$00FF00FF,8}
  108.     !MERGE{d4,d6,d3,#$00FF00FF,8}
  109.  
  110.     MOVE.l  1*4(a0),d1
  111.     MOVE.l  3*4(a0),d3
  112.     MOVE.l  5*4(a0),d5
  113.     MOVE.l  7*4(a0),d7
  114.  
  115.     ADDA.w  #32,a0
  116.     MOVE.l  d4,a6   ;  d3->a6
  117.  
  118.     !MERGEw{d1,d5}
  119.     ADD.l #screensize4*1,a1
  120.     !MERGEw{d3,d7}
  121.     !MERGE{d5,d7,d4,#$00FF00FF,8}
  122.     !MERGE{d1,d3,d4,#$00FF00FF,8}
  123.     !MERGE{d0,d1,d4,#$0F0F0F0F,4}
  124.     !MERGE{d2,d3,d4,#$0F0F0F0F,4}
  125.     !MERGE{d6,d7,d4,#$0F0F0F0F,4}
  126.     EXG.l d1,a6   ;d4-> a6
  127.     !MERGE{d1,d5,d4,#$0F0F0F0F,4}
  128.     ADD.l #screensize4*1,a1
  129.     !MERGE{d0,d1,d4,#$33333333,2}
  130.     !MERGE{d2,d6,d4,#$33333333,2}
  131.     ADD.l #screensize4*1+4,a1
  132.     !MERGE{d3,d7,d4,#$33333333,2}
  133.     EXG.l d1,a6   ;d4=a6
  134.     !MERGE1{d0,d2,d4,#$55555555}
  135.     MOVE.l  d0,plane(a1) ;->Plane 7
  136.     EXG.l d0,a6
  137.     !MERGE{d1,d5,d4,#$33333333,2}
  138.     !MERGE1{d0,d6,d4,#$55555555}
  139.     MOVE.l  d0,a5
  140.     !MERGE1{d1,d3,d4,#$55555555}
  141.     MOVE.l  d2,(a1)
  142.     MOVE.l  d6,a4
  143.     MOVE.l  d1,a3
  144.     SUB.l #screensize4*3,a1
  145.     !MERGE1{d5,d7,d4,#$55555555}
  146.     MOVE.l  d7,a6
  147.     MOVE.l  d3,a2
  148. loop
  149.     TST.w 0*16+6(a0)
  150.     TST.w 1*16+6(a0)
  151.     TST.w 2*16+6(a0)
  152.     TST.w 3*16+6(a0)
  153.  
  154.     TST.w 4*16+6(a0)
  155.     TST.w 5*16+6(a0)
  156.     TST.w 6*16+6(a0)
  157.     TST.w 7*16+6(a0)  ;this is the tricky part
  158.  
  159.     MOVE.l  (a0),d0
  160.     MOVE.l  2*4+0(a0),d2
  161.     MOVE.l  4*4+0(a0),d4
  162.     MOVE.l  6*4+0(a0),d6
  163.  
  164.     MOVE.l  d5,plane(a1) ;  Plane 1
  165.  
  166.     !MERGEw{d0,d4}
  167.     !MERGEw{d2,d6}
  168.  
  169.     !MERGE{d0,d2,d3,#$00FF00FF,8}
  170.     !MERGE{d4,d6,d3,#$00FF00FF,8}
  171.  
  172.     MOVE.l  1*4(a0),d1
  173.     MOVE.l  3*4(a0),d3
  174.     MOVE.l  5*4(a0),d5
  175.     MOVE.l  7*4(a0),d7
  176.  
  177.     ADDA.l  #32,a0
  178.     MOVE.l  a6,(a1)   ;  Plane 0
  179.     MOVE.l  d4,a6   ;  d3->a6
  180.  
  181.     !MERGEw{d1,d5}
  182.     ADD.l #screensize4*1,a1
  183.     !MERGEw{d3,d7}
  184.  
  185.     MOVE.l  a3,plane(a1) ; 3
  186.  
  187.     !MERGE{d5,d7,d4,#$00FF00FF,8}
  188.     !MERGE{d1,d3,d4,#$00FF00FF,8}
  189.     !MERGE{d0,d1,d4,#$0F0F0F0F,4}
  190.     !MERGE{d2,d3,d4,#$0F0F0F0F,4}
  191.     MOVE.l  a2,(a1)   ; 2
  192.     !MERGE{d6,d7,d4,#$0F0F0F0F,4}
  193.     EXG.l d1,a6   ;d4-> a6
  194.     !MERGE{d1,d5,d4,#$0F0F0F0F,4}
  195.     ADD.l #screensize4*1,a1
  196.     MOVE.l  a5,plane(a1) ; 5
  197.  
  198.     !MERGE{d0,d1,d4,#$33333333,2}
  199.     !MERGE{d2,d6,d4,#$33333333,2}
  200.     MOVE.l  a4,(a1)   ; 4
  201.     ADD.l #screensize4*1+4,a1
  202.     !MERGE{d3,d7,d4,#$33333333,2}
  203.     EXG.l d1,a6   ;d4=a6
  204.  
  205.     !MERGE1{d0,d2,d4,#$55555555}
  206.  
  207.     MOVE.l  d0,plane(a1) ;->Plane 7
  208.  
  209.     EXG.l d0,a6
  210.  
  211.     !MERGE{d1,d5,d4,#$33333333,2}
  212.     !MERGE1{d0,d6,d4,#$55555555}
  213.     MOVE.l  d0,a5
  214.     !MERGE1{d1,d3,d4,#$55555555}
  215.     MOVE.l  d2,(a1)
  216.     MOVE.l  d6,a4
  217.     MOVE.l  d1,a3
  218.     SUB.l #screensize4*3,a1
  219.     !MERGE1{d5,d7,d4,#$55555555}
  220.     MOVE.l  d7,a6
  221.     MOVE.l  d3,a2
  222.  
  223.  
  224.     MOVE.l  (a0),d0
  225.     MOVE.l  2*4+0(a0),d2
  226.     MOVE.l  4*4+0(a0),d4
  227.     MOVE.l  6*4+0(a0),d6
  228.  
  229.     MOVE.l  d5,plane(a1) ;  Plane 1
  230.  
  231.     !MERGEw{d0,d4}
  232.     !MERGEw{d2,d6}
  233.  
  234.     !MERGE{d0,d2,d3,#$00FF00FF,8}
  235.     !MERGE{d4,d6,d3,#$00FF00FF,8}
  236.  
  237.     MOVE.l  1*4(a0),d1
  238.     MOVE.l  3*4(a0),d3
  239.     MOVE.l  5*4(a0),d5
  240.     MOVE.l  7*4(a0),d7
  241.  
  242.     ADDA.l  #32,a0
  243.     MOVE.l  a6,(a1)   ;  Plane 0
  244.     MOVE.l  d4,a6   ;  d3->a6
  245.  
  246.     !MERGEw{d1,d5}
  247.     ADD.l #screensize4*1,a1
  248.     !MERGEw{d3,d7}
  249.  
  250.     MOVE.l  a3,plane(a1) ; 3
  251.  
  252.     !MERGE{d5,d7,d4,#$00FF00FF,8}
  253.     !MERGE{d1,d3,d4,#$00FF00FF,8}
  254.     !MERGE{d0,d1,d4,#$0F0F0F0F,4}
  255.     !MERGE{d2,d3,d4,#$0F0F0F0F,4}
  256.     MOVE.l  a2,(a1)   ; 2
  257.     !MERGE{d6,d7,d4,#$0F0F0F0F,4}
  258.     EXG.l d1,a6   ;d4-> a6
  259.     !MERGE{d1,d5,d4,#$0F0F0F0F,4}
  260.     ADD.l #screensize4*1,a1
  261.     MOVE.l  a5,plane(a1) ; 5
  262.  
  263.     !MERGE{d0,d1,d4,#$33333333,2}
  264.     !MERGE{d2,d6,d4,#$33333333,2}
  265.     MOVE.l  a4,(a1)   ; 4
  266.     ADD.l #screensize4*1+4,a1
  267.     !MERGE{d3,d7,d4,#$33333333,2}
  268.     EXG.l d1,a6   ;d4=a6
  269.  
  270.     !MERGE1{d0,d2,d4,#$55555555}
  271.  
  272.     MOVE.l  d0,plane(a1) ;->Plane 7
  273.  
  274.     EXG.l d0,a6
  275.  
  276.     !MERGE{d1,d5,d4,#$33333333,2}
  277.     !MERGE1{d0,d6,d4,#$55555555}
  278.     MOVE.l  d0,a5
  279.     !MERGE1{d1,d3,d4,#$55555555}
  280.     MOVE.l  d2,(a1)
  281.     MOVE.l  d6,a4
  282.     MOVE.l  d1,a3
  283.     SUB.l #screensize4*3,a1
  284.     !MERGE1{d5,d7,d4,#$55555555}
  285.     MOVE.l  d7,a6
  286.     MOVE.l  d3,a2
  287.  
  288.  
  289.     MOVE.l  (a0),d0
  290.     MOVE.l  2*4+0(a0),d2
  291.     MOVE.l  4*4+0(a0),d4
  292.     MOVE.l  6*4+0(a0),d6
  293.  
  294.     MOVE.l  d5,plane(a1) ;  Plane 1
  295.  
  296.     !MERGEw{d0,d4}
  297.     !MERGEw{d2,d6}
  298.  
  299.     !MERGE{d0,d2,d3,#$00FF00FF,8}
  300.     !MERGE{d4,d6,d3,#$00FF00FF,8}
  301.  
  302.     MOVE.l  1*4(a0),d1
  303.     MOVE.l  3*4(a0),d3
  304.     MOVE.l  5*4(a0),d5
  305.     MOVE.l  7*4(a0),d7
  306.  
  307.     ADDA.l  #32,a0
  308.     MOVE.l  a6,(a1)   ;  Plane 0
  309.     MOVE.l  d4,a6   ;  d3->a6
  310.  
  311.     !MERGEw{d1,d5}
  312.     ADD.l #screensize4*1,a1
  313.     !MERGEw{d3,d7}
  314.  
  315.     MOVE.l  a3,plane(a1) ; 3
  316.  
  317.     !MERGE{d5,d7,d4,#$00FF00FF,8}
  318.     !MERGE{d1,d3,d4,#$00FF00FF,8}
  319.     !MERGE{d0,d1,d4,#$0F0F0F0F,4}
  320.     !MERGE{d2,d3,d4,#$0F0F0F0F,4}
  321.     MOVE.l  a2,(a1)   ; 2
  322.     !MERGE{d6,d7,d4,#$0F0F0F0F,4}
  323.     EXG.l d1,a6   ;d4-> a6
  324.     !MERGE{d1,d5,d4,#$0F0F0F0F,4}
  325.     ADD.l #screensize4*1,a1
  326.     MOVE.l  a5,plane(a1) ; 5
  327.  
  328.     !MERGE{d0,d1,d4,#$33333333,2}
  329.     !MERGE{d2,d6,d4,#$33333333,2}
  330.     MOVE.l  a4,(a1)   ; 4
  331.     ADD.l #screensize4*1+4,a1
  332.     !MERGE{d3,d7,d4,#$33333333,2}
  333.     EXG.l d1,a6   ;d4=a6
  334.  
  335.     !MERGE1{d0,d2,d4,#$55555555}
  336.  
  337.     MOVE.l  d0,plane(a1) ;->Plane 7
  338.  
  339.     EXG.l d0,a6
  340.  
  341.     !MERGE{d1,d5,d4,#$33333333,2}
  342.     !MERGE1{d0,d6,d4,#$55555555}
  343.     MOVE.l  d0,a5
  344.     !MERGE1{d1,d3,d4,#$55555555}
  345.     MOVE.l  d2,(a1)
  346.     MOVE.l  d6,a4
  347.     MOVE.l  d1,a3
  348.     SUB.l #screensize4*3,a1
  349.     !MERGE1{d5,d7,d4,#$55555555}
  350.     MOVE.l  d7,a6
  351.     MOVE.l  d3,a2
  352.  
  353. smc
  354.     CMP.l #$0BADC0DE,a0
  355.     BGE   quit
  356.  
  357.     MOVE.l  (a0),d0
  358.     MOVE.l  2*4+0(a0),d2
  359.     MOVE.l  4*4+0(a0),d4
  360.     MOVE.l  6*4+0(a0),d6
  361.  
  362.     MOVE.l  d5,plane(a1) ;  Plane 1
  363.  
  364.     !MERGEw{d0,d4}
  365.     !MERGEw{d2,d6}
  366.  
  367.     !MERGE{d0,d2,d3,#$00FF00FF,8}
  368.     !MERGE{d4,d6,d3,#$00FF00FF,8}
  369.  
  370.     MOVE.l  1*4(a0),d1
  371.     MOVE.l  3*4(a0),d3
  372.     MOVE.l  5*4(a0),d5
  373.     MOVE.l  7*4(a0),d7
  374.  
  375.     ADDA.w  #32,a0
  376.     MOVE.l  a6,(a1)   ;  Plane 0
  377.     MOVE.l  d4,a6   ;  d3->a6
  378.  
  379.     !MERGEw{d1,d5}
  380.     ADD.l #screensize4*1,a1
  381.  
  382.     !MERGEw{d3,d7}
  383.  
  384.     MOVE.l  a3,plane(a1) ; 3
  385.     !MERGE{d5,d7,d4,#$00FF00FF,8}
  386.     !MERGE{d1,d3,d4,#$00FF00FF,8}
  387.     !MERGE{d0,d1,d4,#$0F0F0F0F,4}
  388.     MOVE.l  a2,(a1)   ; 2
  389.     !MERGE{d2,d3,d4,#$0F0F0F0F,4}
  390.     !MERGE{d6,d7,d4,#$0F0F0F0F,4}
  391.     EXG.l d1,a6   ;d4-> a6
  392.     !MERGE{d1,d5,d4,#$0F0F0F0F,4}
  393.     ADD.l #screensize4*1,a1
  394.  
  395.     MOVE.l  a5,plane(a1) ; 5
  396.  
  397.     !MERGE{d0,d1,d4,#$33333333,2}
  398.     !MERGE{d2,d6,d4,#$33333333,2}
  399.     MOVE.l  a4,(a1)   ; 4
  400.     ADD.l #screensize4*1+4,a1
  401.     !MERGE{d3,d7,d4,#$33333333,2}
  402.     EXG.l d1,a6   ;d4=a6
  403.     !MERGE1{d0,d2,d4,#$55555555}
  404.  
  405.     MOVE.l  d0,plane(a1) ;->Plane 7
  406.  
  407.     EXG.l d0,a6
  408.     !MERGE{d1,d5,d4,#$33333333,2}
  409.     !MERGE1{d0,d6,d4,#$55555555}
  410.     MOVE.l  d0,a5
  411.     !MERGE1{d1,d3,d4,#$55555555}
  412.     MOVE.l  d2,(a1)
  413.     MOVE.l  d6,a4
  414.     MOVE.l  d1,a3
  415.     SUB.l #screensize4*3,a1
  416.     !MERGE1{d5,d7,d4,#$55555555}
  417.     MOVE.l  d7,a6
  418.     MOVE.l  d3,a2
  419.  
  420.     JMP loop
  421. quit
  422.     MOVE.l  d5,plane(a1)
  423.     MOVE.l  a6,(a1)
  424.     ADD.l #screensize4*1,a1
  425.     MOVE.l  a3,plane(a1)
  426.     MOVE.l  a2,(a1)
  427.     ADD.l #screensize4*1,a1
  428.     MOVE.l  a5,plane(a1)
  429.     MOVE.l  a4,(a1)
  430.  
  431.     MOVEM.l (a7)+,a3-a6
  432.  
  433.   AsmExit
  434. End Statement
  435.  
  436.  
  437. ; The following program is just a demonstration of how to get the c2p working.
  438. ; You must cludge bitmaps to 8 bytes past the start of the planar buffer,
  439. ; but tell the c2p routine to output to 4 bytes past the start of the planar buffer.
  440. ; This is because it outputs a longword of temporary data to the planar buffer
  441. ; before commencing the conversion, and keeps the bitmap data 64-bit aligned
  442. ; so that if you are working with o/s screens they will use 64-bit datafetch.
  443. .blitzprogram
  444. ; Setup
  445. InitBank 0,(#scrwidth*#scrheight)+1000,2|65536 ; Chipram planar buffer
  446. CludgeBitMap 0,#scrwidth,#scrheight,8,Bank(0)+8
  447. InitPalette 0,256
  448. For c=0 To 255
  449.   AGAPalRGB 0,c,Rnd(c),Rnd(c),Rnd(c)
  450. Next c
  451. AGAPalRGB 0,0,0,0,0
  452. Screen 0,0,0,#scrwidth,#scrheight,8,0,"c2p test",0,0,0
  453. Use Palette 0
  454. VWait 50
  455. baseaddress1.l=AllocMem(#scrwidth*#scrheight,$10000) ; Fastram chunky buffer
  456.  
  457. ; Put something into the chunky buffer so we can see it working
  458. GetReg a0,baseaddress1
  459. MOVE.l  #0,d0
  460. MOVE.l  #screensize-1,d1
  461. cloop
  462.   MOVE.b  d0,(a0)+
  463.   ADDQ.l  #1,d0
  464.   SUBQ.l  #1,d1
  465.   TST.l   d1
  466.   BLT     done
  467.   BRA     cloop
  468. done
  469.  
  470. ; Do the c2p test
  471. VWait 20
  472. Forbid_
  473. VWait
  474. ResetTimer
  475. For time=1 To 800
  476.   c2p{baseaddress1,Bank(0)+4} ; Convert chunky to planar
  477. Next time
  478. t=Ticks
  479. VWait 2 : Permit_
  480. VWait 20
  481. FindScreen 0
  482. Window 0,0,11,640,100,0,"Test results for c2p",0,0
  483. WindowOutput 0
  484. NPrint "Routine performed @ ",50/(t/800),"fps - ",t," ticks"
  485. NPrint " "
  486. NPrint "Press mousebutton..."
  487. Free Screen 0
  488. MouseWait
  489. Free Window 0
  490. End
  491.  
  492.